﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace NFramework.DataAccess
{
    [Serializable]
    public class DataParameterCollection : List<IDbDataParameter>, IDataParameterCollection
    {
        public bool Contains(string parameterName)
        {
            return IndexOf(parameterName) >= 0;
        }

        public int IndexOf(string parameterName)
        {
            return this.FindIndex(param => param.ParameterName == parameterName);
        }

        public void RemoveAt(string parameterName)
        {
            RemoveAt(IndexOf(parameterName));
        }

        public object this[string parameterName]
        {
            get
            {
                return this[IndexOf(parameterName)];
            }
            set
            {
                IDbDataParameter param = this[IndexOf(parameterName)] as IDbDataParameter;
                if (param != null)
                {
                    param.Value = value;
                }
            }
        }
    }
}
